package com.xdf.xzymanagementsystem.enums;

public enum CarryOverType {
    RAW_MATERIAL(0,"jc","jc","材料仓库"),
    SEMI_FINISHED(1,"jk","jk","半成品仓库"),
    ;

    private int index;
    private String flag;
    private String storageId;
    private String desc;

    public String getStorageId() {
        return storageId;
    }

    public void setStorageId(String storageId) {
        this.storageId = storageId;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    CarryOverType(int index,String flag,String storageId, String desc) {
        this.index = index;
        this.flag = flag;
        this.desc = desc;
        this.storageId = storageId;
    }

    // 根据索引返回枚举值
    static CarryOverType of(int index){
        for(CarryOverType item:CarryOverType.values()){
            if(item.getIndex() == index) return item;
        }
        return null;
    }

    public static CarryOverType ofFlag(String flag){
        for(CarryOverType item:CarryOverType.values()){
            if(item.getFlag().equalsIgnoreCase(flag)) return item;
        }
        return null;
    }
}
